<!--
  ~ Copyright (C) 2010 Brockmann Consult GmbH (info@brockmann-consult.de)
  ~
  ~ This program is free software; you can redistribute it and/or modify it
  ~ under the terms of the GNU General Public License as published by the Free
  ~ Software Foundation; either version 3 of the License, or (at your option)
  ~ any later version.
  ~ This program is distributed in the hope that it will be useful, but WITHOUT
  ~ ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  ~ FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for
  ~ more details.
  ~
  ~ You should have received a copy of the GNU General Public License along
  ~ with this program; if not, see http://www.gnu.org/licenses/
  -->

<html>
<head>
    <title>Spectral Unmixing</title>
    <link rel="stylesheet" href="../style.css">
</head>

<body>
<table class="header">
    <tr class="header">
        <td class="header">&nbsp;Spectral Unmixing Tool</td>
        <td class="header" align="right"><a href="nbdocs://org.esa.snap.snap.help/org/esa/snap/snap/help/docs/general/overview/SnapOverview.html"><img src="../images/snap_header.jpg"
                                                                                     border=0></a></td>
    </tr>
</table>

<h3>Introduction</h3>

<p>The spectral unmixing tool is used to decompose a reflectance (or corrected radiance) source spectrum into
    a set of given <i>endmember</i> spectra. The result of the unmixing is a measure of the membership of the
    individual endmember to the source spectrum. This measure is called the endmember's <i>abundance</i>.
    The tool can also compute an error measure for each spectral source band and a summary, root mean square
    error band.
</p>
<p>This tool can be used on multi-resolution products, as long as all source bands used for spectral unmixing share
    the same resolution. In this case, the resulting product uses the GeoCoding of the first source band as geo-location source.</p>

<h3>Algorithm</h3>

<p>The unmixing algorithms are based on the following linear mixing model, which assumes that a spectrum is a linear
    superposition of endmembers:
</p>

<p align="center">
    <img src="images/LSU.png" alt="LSU.png"/>
</p>

<p>The abundances can be computed using three different algorithms:
</p>
<blockquote>
    <ol>
        <li>Unconstrained LSU -
            The abundances are unconstrained and can become any numeric value.
        </li>
        <li>Constrained LSU -
            The sum of abundances equals 1. This is the default unmixing algorithm.
        </li>
        <li>Fully Constrained LSU -
            The sum of abundances equals 1 and abundance values cannot be less than zero.
        </li>
    </ol>
</blockquote>

<p>All algorithms assume that wavelengths are given in nanometers (SNAP's default wavelength unit).
</p>

<h4>User Interfaces</h4>

<p>The spectral unmixing tool can be invoked from the Sentinel Toolbox' tool menu by selecting
    <b>Processing->Image Analysis->Spectral Unmixing...</b> or in batch mode by using the command line tool
    <i><code>gpt</code></i> (Graph Processing Tool) found in the Sentinel Toolbox' <code>bin</code> directory.
    Type <code>gpt Unmix -h</code> to get more information about the usage of the <b>Unmix</b> operator.
</p>

<p>The graphical user interface provided in the Sentinel Toolbox appears as follows:
</p>

<p align="center">
    <img src="images/UnmixDialog.png" alt="UnmixDialog.png"/>
</p>

<h5>Source Product Group</h5>

<p class="i1">
    <b>Name: </b>
    Used to select the spectral source product. The source product shall
    contain spectral bands providing a source spectrum at each pixel. Use the <b>...</b> button to
    open a data product currently not opened in the Sentinel Toolbox.
</p>

<h5>Target Product Group</h5>

<p class="i1">
    <b>Name:</b>
    Used to specify the name of the target product.
</p>

<p class="i1">
    <b>Save to:</b>
    Used to specify whether the target product should be saved to the file system. The
    combo box presents a list of file formats, currently
    BEAM-DIMAP, GeoTIFF, and HDF5.
</p>

<p class="i1">
    <b>Open in ESA SNAP:</b>
    Used to specify whether the target product should be opened in the Sentinel Toolbox.
    When the target product is not saved, it is opened in the Sentinel Toolbox automatically.
</p>

<h5>Parameters Group</h5>

<p class="i1">
    <b>Spectral source bands: </b>
    Used to select the spectral source bands providing a source spectrum at each pixel.
</p>

<p class="i1">
    <b>Abundance band name suffix: </b>
    Provides a name suffix for the generated abundance bands. The suffix is appended to the endmember name.
</p>

<p class="i1">
    <b>Error band name suffix: </b>
    Provides a name suffix for the generated error bands (if any). The suffix is appended to the spectral
    source band name.
</p>

<p class="i1">
    <b>Spectral unmixing model: </b>
    Selects one the linear unmixing algorithms as described above.
</p>

<p class="i1">
    <b>Minimum spectral bandwidth: </b>
    The minimum spectral bandwidth is used find a source band wavelength within the given endmember spectra.
    An enmember wavelength matches a source wavelength if its deviation is within the maximum of the source
    band's inherent bandwidth and the minimum spectral bandwidth. The value is given in nanometers.
</p>

<p class="i1">
    <b>Compute error bands: </b>
    Error bands are computed only if this option is selected.
</p>

<p class="i1">
    <b>Endmembers: </b>
    Lists the endmembers to be used for the unmixing. The tool buttons to the left of the list field
    are used to modify the list of endmembers. They are:
</p>
<blockquote>
    <table>
        <tr>
            <td><b>Add</b></td>
            <td>Opens a text file containing endmembers in character separated format (CSV) and adds
                all endmembers found to the list. The CSV format is described below.
            </td>
        </tr>
        <tr>
            <td><b>Remove</b></td>
            <td>Removes the selected endmember(s) from the list.</td>
        </tr>
        <tr>
            <td><b>Clear</b></td>
            <td>Removes all endmembers from the list.</td>
        </tr>
        <tr>
            <td><b>Export</b></td>
            <td>Exports the endmembers in the list to a CSV text file.</td>
        </tr>
    </table>
</blockquote>

<p>Next to the endmember list is a spectrum diagram which is used to provide a visual feedback about
    the endmembers selected so far. The graph of the endmember selected in the list is displayed bold.
    You can drag the mouse in the diagram in order to display the value of the selected spectrum graph
    at the current cursor position (see screenshot above).
</p>

<h5>Endmember CSV Format</h5>

<p>The CSV format used to import and export endmembers is a plain text format.
    It comprises a header line and a record line for each wavelengths and reflectances
    (or corrected radiances) of the of the endmember spectra. The <b>Tab</b> character is
    used to separate header and record fields. The first header field is assumed to be the
    wavelength in nanometers. Given here is an example of the contents of a CSV endmember file:
</p>

<blockquote>
    <table class="code">
        <tr>
            <td>Wavelength</td>
            <td>Forrest</td>
            <td>Cropland</td>
            <td>Cloud</td>
            <td>Ocean</td>
        </tr>
        <tr>
            <td>412.691</td>
            <td>53.62759</td>
            <td>66.19122</td>
            <td>76.46195</td>
            <td>70.6823</td>
        </tr>
        <tr>
            <td>442.559</td>
            <td>47.280907</td>
            <td>66.45199</td>
            <td>73.67296</td>
            <td>61.99853</td>
        </tr>
        <tr>
            <td>489.882</td>
            <td>35.135273</td>
            <td>64.50155</td>
            <td>66.50564</td>
            <td>46.74277</td>
        </tr>
    </table>
</blockquote>

<hr/>

</body>
</html>